#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll long long
#define XH(i,a,b) for(int i = a; i < b; ++i)
#define XXH(i,b,a) for(int i = b; i >= a; --i)
#define Module 998244353
int tmpInt;ll tmpll;string tmpStr;char tmpChar;
vector<int>tmpIntVector;

struct request{
  int come,leave;
};

bool cmp(request a, request b){
  if(a.come != b.come){
    return a.come < b.come;
  }else{
    return a.leave < b.leave;
  }
}

int maxMount = 0;
vector<request>requests;

int main(){
  int n;
  scanf("%d%*c", &n);
  requests.resize(n);
  int h1,m1,s1,h2,m2,s2;
  XH(i,0,n){
    scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2); 
    requests[i].come = h1 * 3600 + m1 * 60 + s1;
    requests[i].leave = h2 * 3600 + m2 * 60 + s2;
  }
  sort(requests.begin(),requests.end(),cmp);
  vector<int>visit(n);
  int ans = 0;
  XH(i,0,n){
    int left = requests[i].come, right = requests[i].leave;
    if(i == n -1) ans++;
    else if(right < requests[i+1].come){
      ++ans;
      visit[i] = 1;
    }else{
      int choose = i;
      int leap = -1;
      int minleave = right;
      XH(j,i+1,n){
        if(requests[j].come >= minleave){
          leap = j;
          break;
        }
        if(requests[j].leave < minleave){
          minleave = requests[j].leave;
          choose = j;
        }
      }
      ++ans;
      if(leap == -1)break;
      else{
        i = leap - 1;
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}
